<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/view/include/taglib.jsp"%>
<html>
<head>
	<title>日志记录</title>
	<%@ include file="../../include/head.jsp"%>
</head>
<body>
	<div class="admin-content">
		<div class="admin-content-body">
			<div class="am-g ui-tools">
				<div class="am-u-sm-12 am-u-md-6">
					<div class="am-btn-toolbar">
						<div class="am-btn-group am-btn-group-xs">
							<shiro:hasPermission name="sys:slog:edit">
							<!-- 设置是否有删除权限标注 --><c:set var="hasDel" value="true"></c:set>
							<button type="button" id="alldelete" class="am-btn am-btn-danger"><span class="am-icon-trash-o"></span> 删除</button>
							</shiro:hasPermission>
						</div>
					</div>
				</div>
				<div class="am-u-sm-12 am-u-md-3">
					<form id="searchForm" action="${ctx}/slog" method="post">
						<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
						<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
						<div class="am-input-group am-input-group-sm">
							<input type="text" class="am-form-field" name="username" value="${page.entity.username}" placeholder="用户">
							<span class="am-input-group-btn">
								<button class="am-btn am-btn-default" type="submit" onclick="initSearchForm()">搜索</button>
							</span>
						</div>
					</form>
				</div>
			</div>
			<div class="am-g">
				<div class="am-u-sm-12">
					<form class="am-form">
						<table id="contentTable" class="am-table am-table-striped am-table-hover table-main">
							<thead>
								<tr>
									<c:if test="${hasDel}"><th><input name="checkboxall" type="checkbox" style="margin-top: -17px;" /></th></c:if>
									<th>序号</th>
									<th>用户</th>
									<%--<th>菜单</th>--%>
									<th>操作IP</th>
									<th>请求地址</th>
									<th>操作方式</th>
									<th>耗时</th>
									<th>是否异常</th>
									<th>记录时间</th>
									<th>操作</th>
								</tr>
							</thead>
							<tbody>
								<c:forEach items="${page.list}" var="slog" varStatus="status">
									<tr>
										<c:if test="${hasDel}"><td><input name="checkbox" type="checkbox" value="${slog.id}" /></td></c:if>
										<td>${status.index+1}</td>
										<td>${slog.user.username}</td>
										<%--<td>${slog.menu}</td>--%>
										<td>${slog.remoteAddr}</td>
										<td title="${slog.requestUri}">
										<c:choose>
											<c:when test="${fn:length(slog.requestUri)>30}">
												<c:out value="${fn:substring(slog.requestUri, 0, 27)}..." />
											</c:when>
											<c:otherwise>
												<c:out value="${slog.requestUri}" />
											</c:otherwise>
										</c:choose>
										</td>
										<td>${slog.method}</td>
										<td><span class="am-badge am-badge-secondary am-radius">${slog.timeConsuming}</span></td>
										<td>${slog.exception==null?'<span class="am-badge am-badge-success am-radius">正常</span>':'<span class="am-badge am-badge-danger am-radius">异常</span>'}</td>
										<td><fmt:formatDate value="${slog.createDate}" pattern="MM-dd HH:mm:ss" /></td>
										<td><a href="javascript:;" onclick="openModel('日志详细','${ctx}/slog/update?id=${slog.id}')" title="查看详细"><span class="am-icon-eye"></span></a></td>
									</tr>
								</c:forEach>
							</tbody>
						</table>
					</form>
					<%@ include file="../../utils/pagination.jsp"%>
				</div>
			</div>
		</div>
	</div>
	<script type="text/javascript">
		$(document).ready(function() {
			var msg = '${msg}';
			if(msg!=''){
				showMsg(msg);
			}
		});
	</script>
    <script type="text/javascript">
        $(document).ready(function() {
			//多选按钮的全选和反选
			$("input[name='checkboxall']").click(function(){
				$("input[name='checkbox']").prop("checked",$(this).is(":checked"));
			});
			//批量删除
			$("#alldelete").click(function () {
				var ids="";
				$("input[name='checkbox']:checked").each(function(){
					ids+=$(this).val()+",";
				});
				if(ids!=''){
					confirm('确认要批量删除数据吗？','${ctx}/slog/delete?ids='+ids+"&pageNo="+$("#pageNo").val()+"&pageSize="+$("#pageSize").val());
				}else{
					showMsg('请勾选要删除的数据');
				}
			});
        });
    </script>
</body>
</html>
